<?php
require 'weixin.config.php';
$url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".APPID."&secret=".APPSECRET;
$content=file_get_contents($url);
$ret=json_decode($content,true);
$access_token=$ret['access_token'];
function curl_post($url,$data){
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    curl_setopt($curl, CURLOPT_TIMEOUT, 30);
    curl_setopt($curl, CURLOPT_HEADER, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $tmpInfo = curl_exec($curl);
    if (curl_errno($curl)) {
        echo 'Errno'.curl_error($curl);
    }
    curl_close($curl);
    return $tmpInfo;
}
$secen_id=0;
$expire=200;
$data=array(
    'action_name'=>'QR_SCENE',
    'action_info'=>array(
        'scene'=>array(
            'scene_id'=>$secen_id
        )
    ),
    'expire_seconds'=>$expire,
);
$url='https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token='.$access_token;

$content=curl_post($url,json_encode($data));
$result=json_decode($content,true);
//echo $result['ticket'];
$url='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='.$result['ticket'];
echo "<a href='$url' style='font-size: 30px'>展示二维码</a>";